<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>GET</h1>
		<button type="button" onclick="textGet('http://poetry.apiopen.top/getTime')">获取当前日期和时间</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textGet('http://poetry.apiopen.top/sentences')">随机一句名言</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textGet('http://poetry.apiopen.top/poetryFull?count=2&page=1')">获取诗词列表-包含作者信息</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textGet('http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白')">获取诗词作者列表</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textGet('http://poetry.apiopen.top/poetry?count=2&page=1')">获取诗词列表</button>
		<h1>POST</h1>
		<button type="button" onclick="textPost('https://api.apiopen.top/getWangYiNews','1','5','1')">获取网易新闻</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textPost('http://poetry.apiopen.top/sentences','1','1','1')">随机一句名言</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textPost('http://poetry.apiopen.top/poetryFull?count=2&page=1','1','2 ','1')">获取诗词列表-包含作者信息</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textPost('http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白','2','1','1')">获取诗词作者列表</button>&nbsp;&nbsp;&nbsp;
		<button type="button" onclick="textPost('http://poetry.apiopen.top/poetry?count=2&page=1','1','2','1')">获取诗词列表</button>
		<!-- <button type="button" onclick="testPost()">用户反馈</button> -->
	</body>
	<script type="text/javascript">
		function textGet(url){
			var ajax = new XMLHttpRequest();
			ajax.open('GET',url);
			ajax.send();
			ajax.onreadystatechange = function(){
				if(ajax.status == 200 && ajax.readyState == 4){
					//var obj = JSON.parse(ajax.responseText);
					console.log(ajax.responseText);
				}
			}
		}
		function textPost(url,text1,text2,choose){
			var ajax = new XMLHttpRequest();
			ajax.open('POST',url);
			if(choose == '1'){
				ajax.send('page=' + text1 + '&count=' + text2);
			}else if(choose == '2'){
				ajax.send('name=' + text1);
			}
			ajax.onreadystatechange = function(){
				if(ajax.status == 200 && ajax.readyState == 4){
					console.log(ajax.responseText);
				}
			}
		}
	// function testPost(){
	// 	var ajax = new XMLHttpRequest();
	// 	ajax.open('POST','https://api.apiopen.top/getWangYiNews');
	// 	ajax.setRequestHeader('Content-type','application/x-www-form-urlencoded')
	// 	ajax.send('page=1&count=5');			
	// 	ajax.onreadystatechange = function(){
	// 		if(ajax.status == 200 && ajax.readyState==4){
	// 			console.log(ajax.responseText)
	// 		}
	// 	}
	// }
	</script>
</html>
